package com.michael.study.component

import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.michael.study.component.activity.MyActivity
import com.michael.study.component.fragment.FragmentDemoActivity
import com.michael.study.component.service.ServiceActivity
import com.michael.study.library.utils.Actions
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), View.OnClickListener {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        btn_activity.setOnClickListener(this)
        btn_fragment.setOnClickListener(this)
        btn_service.setOnClickListener(this)

        var sharedPreferences = getSharedPreferences("config", Context.MODE_PRIVATE)
        sharedPreferences.edit().clear().putInt("liu", 35).commit()

        Log.d("lgq", "onCreate: " + sharedPreferences.getInt("liu", 0))
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.btn_activity -> {
                Actions.startActivity(this, MyActivity::class.java)
            }

            R.id.btn_fragment -> {
                Actions.startActivity(this, FragmentDemoActivity::class.java)
            }


            R.id.btn_service -> {
                Actions.startActivity(this, ServiceActivity::class.java)
            }
        }
    }
}
